83b0538d3da97e5a81d2829f6215e4589830b362,applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java,ShoppingCartEvents,addToCart,#HttpServletRequest#HttpServletResponse#,112

Before Change


            ProductConfigWorker.fillProductConfigWrapper(configWrapper, request);
            if (!configWrapper.isCompleted()) {
                // The configuration is not valid
                request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource, "cart.addToCart.productConfigurationIsNotValid", locale));
                return "error";
            }
        }

After Change


            ProductConfigWorker.fillProductConfigWrapper(configWrapper, request);
            if (!configWrapper.isCompleted()) {
                // The configuration is not valid
                request.setAttribute("product_id", productId);
                request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage(resource, "cart.addToCart.configureProductBeforeAddingToCart", locale));
                return "product";
            }
        }
        
        //Check for virtual products
        if (ProductWorker.isVirtual(delegator, productId)) {
            request.setAttribute("product_id", productId);
            request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage(resource, "cart.addToCart.chooseVariationBeforeAddingToCart", locale));
            return "product";
        }
        
        // get the override price
        if (paramMap.containsKey("PRICE")) {
            priceStr = (String) paramMap.remove("PRICE");
        } else if (paramMap.containsKey("price")) {
            priceStr = (String) paramMap.remove("price");
        }
        if (priceStr == null) {
            priceStr = "0";  // default price is 0
        }

        // get the renting data
        if ("ASSET_USAGE".equals(ProductWorker.getProductTypeId(delegator, productId))) {
            if (paramMap.containsKey("reservStart")) {
                reservStartStr = (String) paramMap.remove("reservStart");
                if (reservStartStr.length() == 10) // only date provided, no time string?
                        reservStartStr += " 00:00:00.000000000"; // should have format: yyyy-mm-dd hh:mm:ss.fffffffff
                if (reservStartStr.length() >0) {
                    try {
                        reservStart = java.sql.Timestamp.valueOf(reservStartStr);
                    } catch (Exception e) {
                        Debug.logWarning(e,"Problems parsing Reservation start string: "
                                    + reservStartStr, module);
                        reservStart = null;
                        request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource,"cart.addToCart.rental.startDate", locale));
                        return "error";
                    }
                }
                else reservStart = null;
            }

            if (paramMap.containsKey("reservEnd")) {
                reservEndStr = (String) paramMap.remove("reservEnd");
                if (reservEndStr.length() == 10) // only date provided, no time string?
                        reservEndStr += " 00:00:00.000000000"; // should have format: yyyy-mm-dd hh:mm:ss.fffffffff
                if (reservEndStr.length() > 0) {
                    try {
                        reservEnd = java.sql.Timestamp.valueOf(reservEndStr);
                    } catch (Exception e) {
                        Debug.logWarning(e,"Problems parsing Reservation end string: " + reservEndStr, module);
                        reservEnd = null;
                        request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource,"cart.addToCart.rental.endDate", locale));
                        return "error";
                    }
                }
                else reservEnd = null;
            }

            if (reservStart != null && reservEnd != null) {
            	reservLength = new Double(UtilDateTime.getInterval(reservStart,reservEnd)/86400000);
            }

            if (reservStart != null && paramMap.containsKey("reservLength")) {
                reservLengthStr = (String) paramMap.remove("reservLength");
                // parse the reservation Length
                try {
                    reservLength = new Double(nf.parse(reservLengthStr).doubleValue());
                } catch (Exception e) {
                    Debug.logWarning(e,"Problems parsing reservation length string: "
                                    + reservLengthStr, module);
                    reservLength = new Double(1);
                    request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderReservationLengthShouldBeAPositiveNumber", locale));
                    return "error";
                }
            }

            if (reservStart != null && paramMap.containsKey("reservPersons")) {
                reservPersonsStr = (String) paramMap.remove("reservPersons");
                // parse the number of persons
                try {
                    reservPersons = new Double(nf.parse(reservPersonsStr).doubleValue());
                } catch (Exception e) {
                    Debug.logWarning(e,"Problems parsing reservation number of persons string: " + reservPersonsStr, module);
                    reservPersons = new Double(1);
                    request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error,"OrderNumberOfPersonsShouldBeOneOrLarger", locale));
                    return "error";
                }
            }
            
            //check for valid rental parameters
            if (UtilValidate.isEmpty(reservStart) && UtilValidate.isEmpty(reservLength) && UtilValidate.isEmpty(reservPersons)) {
                request.setAttribute("product_id", productId);
                request.setAttribute("_EVENT_MESSAGE_", UtilProperties.getMessage(resource, "cart.addToCart.enterBookingInforamtionBeforeAddingToCart", locale));
                return "product";
            }